$(function () {
    var $userTableForm = $(".user-table-form");
    var settings = {
        url: ctx + "cardInfo/refundCardList",
        pageSize: 10,
        queryParams: function (params) {
            return {
                pageSize: params.limit,
                pageNum: params.offset / params.limit + 1,
                paperid: $userTableForm.find("input[name='paperId']").val().trim(),
                cardno: $userTableForm.find("input[name='cardNo']").val().trim(),
                cardusername: $userTableForm.find("input[name='cardUserName']").val().trim()
            };
        },
        columns: [
            {
                field: 'refundordernum',
                title: '凭证号'
            }, {
                field: 'paperid',
                title: '证件号'
            },  {
                field: 'cardno',
                title: '卡号'
            }, {
                field: 'cardusername',
                title: '持卡人姓名'
            }, {
                field: 'cardtypename',
                title: '卡类型'
            },{
                field: 'syscardbanlance',
                title: '系统卡余额(元)'
            },{
                field: 'cardbanlance',
                title: '卡内余额(元)'
            },{
                field: 'deposit',
                title: '押金'
            },{
                field: 'refundamt',
                title: '退款总金额'
            },{
                field: 'refunddate',
                title: '退卡登记时间'
            },{
                field: 'refundusername',
                title: '退卡操作人'
            },{
                title : '操作',
                field : 'id',
                align : 'center',
                width :  120 ,
                valign : 'middle',
                formatter : function(value,row,index){
                    var e = '<button type="button" class="btn btn-primary" id="print_info" onclick="test(\''+ row.refundordernum + '\')">打印</button> ';
                    return e;
                }
            }]
        };

    $MB.initTable('userTable', settings);
});

function test(t) {
    var par = new Object();
    par.refundordernum = t;
    $.post(ctx+"cardInfo/refundCardList",par,function (r) {
        printInfo(r.rows[0]);
    });
}

function printInfo(row) {

    var LODOP; //声明为全局变量
    LODOP = getLodop(document.getElementById('LODOP_X'),document.getElementById('LODOP_EM'));
    LODOP.NEWPAGEA();
    //LODOP.ADD_PRINT_RECT(10,18,324,392,0,1);
    LODOP.ADD_PRINT_TEXT(20,15,258,54,"三亚一卡通服务凭证");
    LODOP.SET_PRINT_STYLEA(0,"FontName","微软雅黑");
    LODOP.SET_PRINT_STYLEA(0,"fontsize",12);

    LODOP.ADD_PRINT_TEXT(55,65,258,54,"退卡完成");
    LODOP.SET_PRINT_STYLEA(0,"fontsize",9);
    LODOP.SET_PRINT_STYLEA(0,"FontName","微软雅黑");

    LODOP.ADD_PRINT_TEXT(90,3,258,54,"凭证号："+row.refundordernum);
    LODOP.SET_PRINT_STYLEA(0,"fontsize",9);
    LODOP.SET_PRINT_STYLEA(0,"FontName","微软雅黑");

    LODOP.ADD_PRINT_TEXT(120,3,258,54,"卡号："+row.cardno);
    LODOP.SET_PRINT_STYLEA(0,"fontsize",9);
    LODOP.SET_PRINT_STYLEA(0,"FontName","微软雅黑");

    LODOP.ADD_PRINT_TEXT(150,3,258,54,"卡类型："+row.cardtypename);
    LODOP.SET_PRINT_STYLEA(0,"fontsize",9);
    LODOP.SET_PRINT_STYLEA(0,"FontName","微软雅黑");

    LODOP.ADD_PRINT_TEXT(180,3,258,54,"实退卡费："+row.deposit+"元");
    LODOP.SET_PRINT_STYLEA(0,"fontsize",9);
    LODOP.SET_PRINT_STYLEA(0,"FontName","微软雅黑")

    LODOP.ADD_PRINT_TEXT(210,3,258,54,"卡余额："+row.cardbanlance+"元");
    LODOP.SET_PRINT_STYLEA(0,"fontsize",9);
    LODOP.SET_PRINT_STYLEA(0,"FontName","微软雅黑")

    LODOP.ADD_PRINT_TEXT(240,3,258,54,"实退总金额："+row.refundamt+"元");
    LODOP.SET_PRINT_STYLEA(0,"fontsize",9);
    LODOP.SET_PRINT_STYLEA(0,"FontName","微软雅黑")

    LODOP.ADD_PRINT_TEXT(270,3,258,54,"操作人："+row.refundusername);
    LODOP.SET_PRINT_STYLEA(0,"fontsize",9);
    LODOP.SET_PRINT_STYLEA(0,"FontName","微软雅黑")

    LODOP.ADD_PRINT_TEXT(300,3,258,54,"退卡日期："+row.refunddate);
    LODOP.SET_PRINT_STYLEA(0,"fontsize",9);
    LODOP.SET_PRINT_STYLEA(0,"FontName","微软雅黑")

    //设定打印页面大小
    LODOP.SET_PRINT_PAGESIZE(3,590,55,"");
    LODOP.SET_PRINT_COPIES(2);
    LODOP.PRINT();
    //LODOP.PREVIEW();
    if (needCLodop()) {
        window.On_CLodop_Opened=function(){
            OpenPreview();
            window.On_CLodop_Opened=null;
        };
    } else
        window.onload = function(){
            OpenPreview();
        };
    $MB.n_success("打印完成");
}

function search() {
    $MB.refreshTable('userTable');
}

